// 权限控制
// 登录权限控制
import router from '@/router'
// import store from '@/store'
import { getToken } from '@/utils/auth' // get token from cookie
// 定义一个白名单数组
const WHITE_LIST = ['/login', '/404']
router.beforeEach((to, from, next) => {
  // const token = store.state.user.token
  if (getToken()) {
    if (to.path === '/login') {
      next('/')
    } else {
      next()
    }
  } else {
    if (WHITE_LIST.includes(to.path)) {
      next()
    } else {
      next('/login')
    }
  }
})
